home *** CD-ROM | disk | FTP | other *** search
- #include <stdlib.h>
-
- #include <clib/exec_protos.h>
- #include <clib/dos_protos.h>
- #include <clib/graphics_protos.h>
- #include <clib/feelin_protos.h>
-
- #include <graphics/gfx.h>
- #include <graphics/rastport.h>
- #include <libraries/feelin.h>
-
- struct FeelinBase *FeelinBase;
-
- /// OBJ
- /* Here is the beginning of our simple new class... */
-
- #define FM_Strobo FCCM_BASE
-
- struct LocalObjectData {
- struct FeelinSignalHandler psSignalHandler;
- };
- //+
-
- /// mNew
- ULONG SAVEDS mNew(struct FeelinClass *psClass,APTR Obj,struct LocalObjectData *psLOD,ULONG *pnArgs)
- {
- psLOD -> psSignalHandler.Object = Obj;
- psLOD -> psSignalHandler.Method = FM_Strobo;
- psLOD -> psSignalHandler.Flags = FF_SignalHandler_Timer;
- psLOD -> psSignalHandler.Signals = 0; // Secs
- psLOD -> psSignalHandler.Reserved = 30000; // Micros
-
- return F_SuperDoA(psClass,Obj,FM_New,pnArgs);
- }
- //+
- /// mAskMinMax
- /*
- AskMinMax method will be called before the window is opened and before
- layout takes place. We need to tell Feelin the minimum and maximum size of
- our object. Note that we indeed need to *add* these values, not just set
- them !
- */
-
- ULONG SAVEDS mAskMinMax(struct FeelinClass *psClass,APTR Obj,ULONG *pnArgs)
- {
-
- _minw(Obj) += 30;
- _minh(Obj) += 30;
-
- /*
- Now call our superpsClassass. Area.fcc will handle everything, taking care of
- FA_FixedXxx, FA_MinXxx and FA_MaxXxx.
- */
-
- return F_SuperDoA(psClass,Obj,FM_AskMinMax,pnArgs);
- }
- //+
- /// mDraw
- /*
- Draw method is called whenever Feelin feels (obviously ;-)) we should
- render our object. This usually happens after layout is finished. Note: You
- may only render within the rectangle _mleft(paObj), _mtop(paObj), _mwidth(paObj),
- _mheight(paObj).
- */
- ULONG SAVEDS mDraw(struct FeelinClass *psClass,APTR Obj,struct FS_Draw *psDraw)
- {
- struct RastPort *rp;
-
- rp = _rp(Obj);
-
- /*
- let our superclass draw itself first, Area class would e.g. draw the frame
- and clear the whole region. What it does exactly depends on flags.
- */
-
- F_SuperDoA(psClass,Obj,FM_Draw,(ULONG *)psDraw);
-
- _APen(rand());
- _Boxf(_mx(Obj),_my(Obj),_mx2(Obj),_my2(Obj));
-
- return NULL;
- }
- //+
- /// mShow
- ULONG SAVEDS mShow(struct FeelinClass *psClass,APTR Obj,struct LocalObjectData *psLOD,ULONG *pnArgs)
- {
- F_SuperDoA(psClass,Obj,FM_Show,pnArgs);
- F_Do(_client(Obj),FM_Client_AddSignalHandler,&psLOD -> psSignalHandler);
- return NULL;
- }
- //+
- /// mHide
- ULONG SAVEDS mHide(struct FeelinClass *psClass,APTR Obj,struct LocalObjectData *psLOD,ULONG *pnArgs)
- {
- F_Do(_client(Obj),FM_Client_RemSignalHandler,&psLOD -> psSignalHandler);
- return F_SuperDoA(psClass,Obj,FM_Hide,pnArgs);
- }
- //+
- ///myDispatcher
- /*
- Here comes the dispatcher for our custom psClassass. Unknown/unused methods are
- passed to the superclass immediately.
- */
-
- ULONG ASM SAVEDS myDispatcher(REG_A2 struct FeelinClass *psClass,REG_A0 APTR Obj,REG_D0 ULONG nMethod,REG_A1 ULONG *pnArgs)
- {
- struct LocalObjectData *psLOD = INST_DATA(psClass,Obj);
-
- switch (nMethod)
- {
- case FM_New: return mNew (psClass,Obj,psLOD,pnArgs);
-
- case FM_Show: return mShow (psClass,Obj,psLOD,pnArgs);
- case FM_Hide: return mHide (psClass,Obj,psLOD,pnArgs);
- case FM_AskMinMax: return mAskMinMax (psClass,Obj,pnArgs);
- case FM_Draw: return mDraw (psClass,Obj,(struct FS_Draw *)pnArgs);
-
- case FM_Strobo: F_Draw(Obj,FF_Draw_Update);
- return TRUE;
-
- default: return F_SuperDoA(psClass,Obj,nMethod,pnArgs);
- }
- }
- //+
-
- ///Main
- void main()
- {
- APTR c,w;
- struct FeelinClass *cc;
-
- if (FeelinBase = (struct FeelinBase *)OpenLibrary("feelin.library",FV_VERSION))
- {
-
- /*
- Create the new custom class with a call to F_CreateClassA().
-
- This function returns a struct FeelinClass. You must use cc -> ID to create
- instance of your custom class. This ID is unique and made by
- F_CreateClassA().
- */
-
- if (cc = F_CreateClass(FA_SuperID, FC_Area,
- FA_DataSize, sizeof (struct LocalObjectData),
- FA_Dispatcher, myDispatcher,
- TAG_DONE))
- {
- c = ClientObject,
- FA_Client_Title, "Class2",
- FA_Client_Version, "$VER: Class2 0.02 (22.10.01)",
- FA_Client_Copyright, "© 2001 by Laviale Olivier",
- FA_Client_Author, "Laviale Olivier (lotan9@aol.com)",
- FA_Client_Description, "Tutorial on Client.AddInputHandler()",
- FA_Client_Base, "CLASS2",
-
- Child, w = WindowObject,
- FA_ID, "MAIN",
- FA_Window_Title, "Crazy colors using Client.AddSignalHandler()",
-
- Child, VGroup,
- Child, HGroup,
- Child, F_NewObj(cc -> ID,GaugeFrame, DontChain, TAG_DONE),
- Child, F_NewObj(cc -> ID,GaugeFrame, DontChain, TAG_DONE),
- End,
-
- Child, HGroup,
- Child, F_NewObj(cc -> ID,GaugeFrame, DontChain, TAG_DONE),
- Child, F_NewObj(cc -> ID,GaugeFrame, DontChain, TAG_DONE),
- End,
- End,
- End,
- End;
-
- if (c)
- {
- F_Do(w,FM_Notify,FA_Window_CloseRequest,TRUE, FV_Notify_Client,2,FM_Client_ReturnID,FV_Client_Quit);
- F_Set(w,FA_Window_Open,TRUE);
-
- F_DoA(c,FM_Client_Run,NULL);
-
- F_DisposeObj(c);
- }
-
- F_RemoveClass(cc);
- }
- else
- {
- Printf("Unable to create custom class.\n");
- }
-
- CloseLibrary((struct Library *)FeelinBase);
- }
- else
- {
- Printf("Failed to open feelin.library.\n");
- }
- }
- //+
-